import Vue from 'vue';
import iView from 'iview';
import {router} from './router/index';
import {appRouter,
        appRouterBaseManagement,
        appRouterSystemManagement,
        appRouterFuwuServerManagement,
        appRouterXieTongManagement,
        appRouterTongJiManagement,
        appRouterServerResourceManagement,
        appRouterServiceInterfaceManagement,
        appRouterServiceRequestManagement,
        appRouterServiceStatisticsReport,
        appRouterServiceMonitoringLog,
        appRouterApplicationManagement,
        appRouterApplicationLogManagement,
        appRouterApplicationOfEvaluationManagement,
        appRouterApplicationAudit,
        appRouterAnOverviewOfApplicationStatistics,
        appRouterApplicationStatistics,
} from './router/router';
import store from './store';
import App from './app.vue';
import '@/locale';
import 'iview/dist/styles/iview.css';
import VueI18n from 'vue-i18n';
import util from './libs/util';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios';
import echarts from 'echarts';
import $ from 'jquery';
// 引入自己的css
import './views/api/css/css.css';

Vue.use(VueI18n);
Vue.use(iView);
Vue.use(ElementUI);
Vue.use(echarts);
Vue.use($);
Vue.prototype.$echarts = echarts;
Vue.prototype.$http = axios;
Vue.prototype.$jq = $;

new Vue({
    el: '#app',
    router: router,
    store: store,
    render: h => h(App),
    data: {
        currentPageName: ''
    },
    mounted () {
        this.currentPageName = this.$route.name;
        // 显示打开的页面的列表
        this.$store.commit('setOpenedList');
        this.$store.commit('initCachepage');
        // 权限菜单过滤相关
        // this.$store.commit('updateMenulist');
        // iview-admin检查更新
        util.checkUpdate(this);
    },
    created () {
        let tagsList = [];
        appRouter.map((item) => {
            if (item.children.length <= 1) {
                tagsList.push(item.children[0]);
            } else {
                tagsList.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsList);

        let tagsListBaseManagement = [];
        appRouterBaseManagement.map((item) => {
            if (item.children.length <= 1) {
                tagsListBaseManagement.push(item.children[0]);
            } else {
                tagsListBaseManagement.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListBaseManagement);

        let tagsListSystemManagement = [];
        appRouterSystemManagement.map((item) => {
            if (item.children.length <= 1) {
                tagsListSystemManagement.push(item.children[0]);
            } else {
                tagsListSystemManagement.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListSystemManagement);

		let tagsListFuwuServerManagement = [];/*业务协同*/
        appRouterFuwuServerManagement.map((item) => {
            if (item.children.length <= 1) {
                tagsListFuwuServerManagement.push(item.children[0]);
            } else {
                tagsListFuwuServerManagement.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListFuwuServerManagement);


		let tagsListXieTongManagement = [];/*业务协同*/
        appRouterXieTongManagement.map((item) => {
            if (item.children.length <= 1) {
                tagsListXieTongManagement.push(item.children[0]);
            } else {
                tagsListXieTongManagement.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListXieTongManagement);

		
		let tagsListTongJiManagement = [];/*统计报表*/
        appRouterTongJiManagement.map((item) => {
            if (item.children.length <= 1) {
                tagsListTongJiManagement.push(item.children[0]);
            } else {
                tagsListTongJiManagement.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListTongJiManagement);
		
		
		let tagsListServerResourceManagement = [];/*服务资源*/
        appRouterServerResourceManagement.map((item) => {
            if (item.children.length <= 1) {
                tagsListServerResourceManagement.push(item.children[0]);
            } else {
                tagsListServerResourceManagement.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListServerResourceManagement);


        let tagsListServiceInterfaceManagement = [];
        appRouterServiceInterfaceManagement.map((item) => {
            if (item.children.length <= 1) {
                tagsListServiceInterfaceManagement.push(item.children[0]);
            } else {
                tagsListServiceInterfaceManagement.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListServiceInterfaceManagement);

        let tagsListServiceRequestManagement = [];
        appRouterServiceRequestManagement.map((item) => {
            if (item.children.length <= 1) {
                tagsListServiceRequestManagement.push(item.children[0]);
            } else {
                tagsListServiceRequestManagement.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListServiceRequestManagement);

        let tagsListServiceStatisticsReport = [];
        appRouterServiceStatisticsReport.map((item) => {
            if (item.children.length <= 1) {
                tagsListServiceStatisticsReport.push(item.children[0]);
            } else {
                tagsListServiceStatisticsReport.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListServiceStatisticsReport);

        let tagsListServiceMonitoringLog = [];
        appRouterServiceMonitoringLog.map((item) => {
            if (item.children.length <= 1) {
                tagsListServiceMonitoringLog.push(item.children[0]);
            } else {
                tagsListServiceMonitoringLog.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListServiceMonitoringLog);

        let tagsListApplicationManagement = [];
        appRouterApplicationManagement.map((item) => {
            if (item.children.length <= 1) {
                tagsListApplicationManagement.push(item.children[0]);
            } else {
                tagsListApplicationManagement.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListApplicationManagement);

        let tagsListApplicationLogManagement = [];
        appRouterApplicationLogManagement.map((item) => {
            if (item.children.length <= 1) {
                tagsListApplicationLogManagement.push(item.children[0]);
            } else {
                tagsListApplicationLogManagement.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListApplicationLogManagement);

        let tagsListApplicationOfEvaluationManagement = [];
        appRouterApplicationOfEvaluationManagement.map((item) => {
            if (item.children.length <= 1) {
                tagsListApplicationOfEvaluationManagement.push(item.children[0]);
            } else {
                tagsListApplicationOfEvaluationManagement.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListApplicationOfEvaluationManagement);

        let tagsListApplicationAudit = [];
        appRouterApplicationAudit.map((item) => {
            if (item.children.length <= 1) {
                tagsListApplicationAudit.push(item.children[0]);
            } else {
                tagsListApplicationAudit.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListApplicationAudit);

        let tagsListAnOverviewOfApplicationStatistics = [];
        appRouterAnOverviewOfApplicationStatistics.map((item) => {
            if (item.children.length <= 1) {
                tagsListAnOverviewOfApplicationStatistics.push(item.children[0]);
            } else {
                tagsListAnOverviewOfApplicationStatistics.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListAnOverviewOfApplicationStatistics);

        let tagsListApplicationStatistics = [];
        appRouterApplicationStatistics.map((item) => {
            if (item.children.length <= 1) {
                tagsListApplicationStatistics.push(item.children[0]);
            } else {
                tagsListApplicationStatistics.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsListApplicationStatistics);

    }
});
